Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract non-generic members from frequently used generic types #16585

Merged
merged 2 commits into from
Sep 14, 2024

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Aug 3, 2024

What does the pull request do?

This PR:

  • Extracts some non-generic code paths from generic types or methods that have a lot of instantiations, such as StyledProperty<T> or AvaloniaObject.Bind<T>.
  • Extracts common generic code in EffectiveValue<T> into separate methods (the extra call is completely negligible in this case).
  • Moves some common static non-generic fields outside of the generic types.
  • Slightly change the flow of StyledProperty<T>.ShouldSetValue() and PropertyNotifying (without any behavioral change), for better codegen.

On a NativeAOT hello world built for win-x64, this removes 324 KB of native code.
This will also help standard JIT builds with less work to do, and fewer allocations of duplicate fields.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050895-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Copy link
Member

@maxkatz6 maxkatz6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was afraid these changes would make it way harder to read, but it looks fine for me.
Nice improvement either way.

@maxkatz6 maxkatz6 merged commit e3c6418 into AvaloniaUI:master Sep 14, 2024
11 checks passed
@MrJul MrJul deleted the feature/aot-extract-non-generic branch September 19, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants